package com.jron.cqiu.kernel.scheduler;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import com.jron.cqiu.kernel.regist.IAutorun;
import com.jron.cqiu.util.ConfigurationUtil;

/**
 * Created by Intellij IDEA.
 *
 * @Author: Yejw
 * @Date: 2008-6-23
 * @Time: 10:46:47
 */
public class StartupScheduler implements Job {

    /**
     * <p>
     * Called by the <code>{@link org.quartz.Scheduler}</code> when a <code>{@link org.quartz.Trigger}</code>
     * fires that is associated with the <code>Job</code>.
     * </p>
     * <p/>
     * <p>
     * The implementation may wish to set a
     * {@link org.quartz.JobExecutionContext#setResult(Object) result} object on the
     * {@link org.quartz.JobExecutionContext} before this method exits.  The result itself
     * is meaningless to Quartz, but may be informative to
     * <code>{@link org.quartz.JobListener}s</code> or
     * <code>{@link org.quartz.TriggerListener}s</code> that are watching the job's
     * execution.
     * </p>
     *
     * @throws org.quartz.JobExecutionException
     *          if there is an exception while executing the job.
     */
    public void execute(JobExecutionContext context) throws JobExecutionException {
        IAutorun autorun = IAutorun.INSTANCE;
        if (!autorun.isExist(IAutorun.AUTORUN_NAME))
            autorun.add(IAutorun.AUTORUN_NAME, ConfigurationUtil.value("startup.value"));
    }
}
